{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a20a2420",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Properties of the finite field GF(4): Galois Field:\n",
      "  name: GF(2^2)\n",
      "  characteristic: 2\n",
      "  degree: 2\n",
      "  order: 4\n",
      "  irreducible_poly: x^2 + x + 1\n",
      "  is_primitive_poly: True\n",
      "  primitive_element: x\n",
      "Elements of the finite field GF(4): [0 1 2 3]\n",
      "Addition table of the finite field GF(4)\n"
     ]
    },
    {
     "ename": "NameError",
     "evalue": "name 'GF7' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m/var/folders/xz/sj6gs0f150n67pbx3mg32v3c0000gn/T/ipykernel_31224/1038025911.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      7\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Addition table of the finite field GF(4)\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mGF7\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marithmetic_table\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"+\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      9\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Multiplication table of the finite field GF(4)\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     10\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mGF7\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marithmetic_table\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"*\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mNameError\u001b[0m: name 'GF7' is not defined"
     ]
    }
   ],
   "source": [
    "import galois\n",
    "\n",
    "GF4 = galois.GF(4)\n",
    "print(\"Properties of the finite field GF(4):\", GF4.properties)\n",
    "print(\"Elements of the finite field GF(4):\", GF4.elements)\n",
    "\n",
    "print(\"Addition table of the finite field GF(4)\")\n",
    "print(GF4.arithmetic_table(\"+\"))\n",
    "print(\"Multiplication table of the finite field GF(4)\")\n",
    "print(GF4.arithmetic_table(\"*\"))\n",
    "\n",
    "## Output Example\n",
    "# Properties of the finite field GF(4): Galois Field:\n",
    "#   name: GF(2^2)\n",
    "#   characteristic: 2\n",
    "#   degree: 2\n",
    "#   order: 4\n",
    "#   irreducible_poly: x^2 + x + 1\n",
    "#   is_primitive_poly: True\n",
    "#   primitive_element: x\n",
    "# Elements of the finite field GF(4): [0 1 2 3]\n",
    "# Addition table of the finite field GF(4)\n",
    "# x + y | 0  1  2  3 \n",
    "# ------|------------\n",
    "#     0 | 0  1  2  3 \n",
    "#     1 | 1  0  3  2 \n",
    "#     2 | 2  3  0  1 \n",
    "#     3 | 3  2  1  0 \n",
    "# Multiplication table of the finite field GF(4)\n",
    "# x * y | 0  1  2  3 \n",
    "# ------|------------\n",
    "#     0 | 0  0  0  0 \n",
    "#     1 | 0  1  2  3 \n",
    "#     2 | 0  2  3  1 \n",
    "#     3 | 0  3  1  2 \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e98f60f5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
